<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?=$frs['filename']?></title>
<link rel="stylesheet" type="text/css" href="res/css/css.css"/>
<script type="text/javascript" src="res/js/jquery.js"></script>
<script type="text/javascript" src="res/js/js.js"></script>
<style>
<?php
$col = getconfig('apptheme','#6699CC');
echo 'body{--main-color:'.$col.'}';
?>
</style>
<script>
var key='<?=$da['key']?>';
function zhuang(o){
	var o1 = $(o).parent();
	o1.html(js.getmsg('发送转化中...'));
	js.ajax({
		url:'?m=file&a=changetopdf&key='+key+'',
		dataType:'json',
		success:function(det){
			if(det.success){
				o1.html(js.getmsg('√ 已发送，大概在<font color=red id="times">20</font>秒后可刷新查看', 'green')+'，<a href="javascript:;" class="zhu" onclick="location.reload()">[刷新看一下]</a>');
				localpath=det.data.localpath;
				timeshow(parseFloat(det.data.times));
				js.msg('success','已发送，文件越大等待时间越长');
			}else{
				o1.html(js.getmsg(det.msg, 'red'));
			}
		}
	});
}

function timeshow(s){
	if(!get('times'))return;
	$('#times').html(s);
	if(s==0){
		ztpanduan(true);
		return;
	}
	if(s%3==0)ztpanduan(false);
	setTimeout('timeshow('+(s-1)+')',1000);
}
function ztpanduan(lbos){
	var url = '?m=file&a=officestatus&key='+key+'&localpath='+localpath+'';
	$.get(url,function(res){
		var det = js.decode(res);
		if(det.success){
			var da = det.data;
			if(da.status=='1'){
				if(da.ftype=='1'){
					doanpdf();
				}else{
					location.reload();
				}
			}else{
				if(lbos)js.setmsg('预览请求处理超时，<a href="javascript:;" class="zhu" onclick="location.reload()">[刷新重试]</a>','red','showtishi');
			}
		}else{
			js.msg('msg', det.msg);
			js.setmsg(det.msg,'red','showtishi');
		}
	});	
}

function doanpdf(){
	js.setmsg('已经转化完成正在下载中...','','showtishi');
	var url = '?m=file&a=officedown&key='+key+'';
	$.get(url,function(res){
		var det = js.decode(res);
		if(det.success){
			location.reload();
		}else{
			js.msg('msg', det.msg);
			js.setmsg(det.msg,'red','showtishi');
		}
	});
}
</script>
</head>
<body style="padding:0px;margin:0px;">



<div align="center"  style="font-size:16px;margin-top:40px">
	<div style="line-height:40px"><?=$frs['filename']?>(<?=$frs['filesizecn']?>)</div>
	<div>正要预览[<?=$frs['fileext']?>]类型的文件。</div>
	
	<div id="showtishi" style="margin-top:15px">
		<button type="button" style="border-radius:5px" onclick="zhuang(this)" class="webbtn">发送预览请求</button>&nbsp; <a class="zhu" href="javascript:;" onclick="location.reload()">[刷新]</a></div>
	</div>


</body>
</html>